#pragma once

#ifdef __WINDOWS__

#pragma warning( disable : 4311 )
#pragma warning( disable : 4312 )

#endif

template<typename T>
class CSingleTon
{
protected:

	static T* m_pSingleton;

public:
	

	CSingleTon( void )
	{
#if defined( _MSC_VER ) && _MSC_VER < 1200	 
		int offset = (int)(T*)1 - (int)(CSingleTon <T>*)(T*)1;
		m_pSingleton = (T*)((int)this + offset);
#else
		m_pSingleton = static_cast< T* >( this );
#endif

	}

	~CSingleTon(void)
	{
	   m_pSingleton = 0;
	}

	static inline T& GetSingleton(void)
	{  return (*m_pSingleton);
	}

	static inline T* GetSingletonPtr(void)
	{  return m_pSingleton;
	}
};

template <typename T>
T* CSingleTon<T>::m_pSingleton = 0;